cc.Class({
    extends: cc.Component,

    properties: {
        isCustom: {
            default: true,
            notify() {
                //设置数值后更新一次
                this._updateCustom();
            }
        },
        isExtractWidth: true,
        isExtractHeight: true
    },

    _updateCustom() {
        if (!this.isCustom) {
            this.isExtractWidth = cc.Canvas.instance.fitHeight;
            this.isExtractHeight = cc.Canvas.instance.fitWidth;
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad: function () {
        const ratioX = cc.view.getCanvasSize().width / cc.view.getVisibleSizeInPixel().width;
        const ratioY = cc.view.getCanvasSize().height / cc.view.getVisibleSizeInPixel().height;
        if (!this.isCustom) {
            this.node.scaleX = this.node.scaleX * ratioX;
            this.node.scaleY = this.node.scaleY * ratioY;
        } else {
            if (this.isExtractWidth && this.isExtractHeight) {
                this.node.width = this.node.width * ratioX;
                this.node.height = this.node.height * ratioY;

            } else if (this.isExtractWidth && !this.isExtractHeight) {
                this.node.width = this.node.width * ratioX;
            } else if (!this.isExtractWidth && this.isExtractHeight) {
                this.node.height = this.node.height * ratioY;
            } else {
                this.node.width = this.node.width * ratioX;
                this.node.height = this.node.height * ratioY;
            }
        }
    }
});
